﻿<UserControl x:Class="UserCardPrinter.UserCardPrinterView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="700">
    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Print user cards" FontSize="16" FontWeight="Bold" Grid.ColumnSpan="2" Margin="8" Foreground="#445566" HorizontalAlignment="Center"/>
        <Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="4" DataContext="{Binding LayoutManager}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50*"/>
                <ColumnDefinition Width="50*"/>
            </Grid.ColumnDefinitions>
            <ListBox Grid.Column="0" ItemsSource="{Binding Layouts}" SelectedItem="{Binding SelectedLayout,Mode=TwoWay}" Margin="4" VerticalAlignment="Top">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Background="#c0d0e0" Margin="2">
                            <TextBlock Text="{Binding Name}" FontSize="14"/>
                            <ItemsControl ItemsSource="{Binding Elements}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Border BorderBrush="Black" BorderThickness="1" Padding="2" CornerRadius="3" Background="White">
                                            <Viewbox Height="80" >
                                                <ContentPresenter Content="{Binding Value}" />
                                            </Viewbox>
                                        </Border>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <ListBox Grid.Column="1" ItemsSource="{Binding Papers}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                     SelectedItem="{Binding SelectedPaper,Mode=TwoWay}" Margin="4" VerticalAlignment="Stretch">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="14" TextWrapping="Wrap" Margin="2"/>

                            <Viewbox Width="120" >
                                <Border Background="White" Margin="2">
                                <ContentPresenter Content="{Binding Layout}" />
                                </Border>
                            </Viewbox>

                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
        <Button Grid.Row="2" Content="Print" Height="31" HorizontalAlignment="Right" Margin="0,8,16,16" 
                VerticalAlignment="Bottom" Width="83" Command="{Binding PrintCommand}"/>
    </Grid>
</UserControl>
